/*
** game.c for game in /home/vriely/Dropbox/work/Unix/Zappy_none/serv-src
**
** Made by Samuel Vrielynck
** Login   <vriely_s@epitech.net>
**
** Started on  Wed May 23 12:17:08 2012 Samuel Vrielynck
** Last update Thu Jul 19 17:38:43 2012 pierrick druart
*/

#include	<stdio.h>
#include	<string.h>
#include	<stdlib.h>

#include	"server.h"

void	       	check_team_concat(t_client *client,
    struct s_team *team, t_game *game)
{
  client->send->concat_value(client->send, team->slot);
  client->send->concat(client->send, "\n");
  client->send->concat_value(client->send, game->coord.x);
  client->send->concat(client->send, " ");
  client->send->concat_value(client->send, game->coord.y);
  client->send->concat(client->send, "\n");
}

void   		play(t_client *client, t_game *game,
    long unsigned int elapsed_time)
{
  if (client->gamer->action > 0)
    elapsed_time > client->gamer->action ? (client->gamer->action = 0) :
      (client->gamer->action = client->gamer->action - elapsed_time);
  if (client->gamer->action == 0)
  {
    if (client->gamer->action_str != NULL)
    {
      client->send->concat(client->send, client->gamer->action_str);
      free(client->gamer->action_str);
      client->gamer->action_str = NULL;
    }
    if (client->gamer->task->len > 0)
      gere_task(client, game);
  }
  getsleeptime(&(game->sleep), client->gamer->food);
  getsleeptime(&(game->sleep), client->gamer->action);
}
